  // 处理POST请求
 const getPostData = (req) => {
    return new Promise((res, rej) => {
      if (req.method !== 'POST' && req.method !== 'PUT') {
        res({})
        return
      }
      // 接收的数据
      let postData = ''
      req.on('data', chunk => {
        postData += chunk.toString()
      })
      req.on('end', () => {
        if (!postData) {
          res({})
          return 
        }
        res(JSON.parse(postData))
      })
    })
  }

module.exports = {
  getPostData
}